/*
 * Date         Author     Note
 * 2014.11.24   wzwz       工作参数窗口
 * 2015.04.28   wzwz       增加二段度目等参数
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include "resource.h"
#include "func.h"
#include "lang.h"
#include "work.h"
#include "com.h"
#include "mhlabel.h"
#include "keypane.h"
#include "mh/common.h"
#include "run.h"
#include "info.h"

#define START_POINT_CAPTION_WIDTH       160
#define START_POINT_CAPTION_HEIGHT      24
#define START_POINT_NAME_WIDTH          60
#define START_POINT_CAPTION_LEFT        (CX_EDGE_LEFT * 2)
#define START_POINT_CAPTION_TOP         (CY_TITLE4_HEIGHT + CX_EDGE_LEFT * 2 - 10)
#define START_POINT_INTER               6
/*
 *
 */
static void CreateWorkInterface(HWND hWnd)
{
    char sc[256] = {0};
    //sys btn
    CreateWindow (MH_STATIC_NAME,
        "",
        WS_CHILD | WS_VISIBLE,
        ID_ESC,
        CX_XTCS_WND_BMP - CX_ASK_BMP * 2,
        10,
        CX_ASK_BMP,
        CY_ASK_BMP,
        hWnd, (int)&g_bmp[BMP_FALSE]);

    CreateWindow (MH_STATIC_NAME,
        "",
        WS_CHILD | WS_VISIBLE,
        ID_ESC,
        CX_XTCS_WND_BMP - CX_ASK_BMP * 3 - 8,
        10,
        CX_ASK_BMP,
        CY_ASK_BMP,
        hWnd, (int)&g_bmp[BMP_TRUE]);
    CreateWindow (MH_STATIC_NAME,
        "",
        WS_CHILD | WS_VISIBLE,
        ID_ESC,
        CX_XTCS_WND_BMP - CX_ASK_BMP * 4 - 8 * 2,
        10,
        CX_ASK_BMP,
        CY_ASK_BMP,
        hWnd, (int)&g_bmp[BMP_ASK]);
    //left
    CreateWindow (MH_LABEL_NAME,
        MW_FLW_START_POINT_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetStartNeedle(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_START_POINT,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_SPEED_LOW_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 1,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetMacLowSpeed(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_LOW_SPEED,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 1,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        GetString(606)/*MW_RESET_SPEED_CAPTION*/,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 2,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    //sprintf(sc, "%u", GetMacResetSpeed(g_knit_data));
    sprintf(sc, "%u", GetMacEmptySpeed(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_RESET_SPEED,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 2,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_MID_SPEED_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 3,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetMacMidSpeed(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_MID_SPEED,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 3,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_HIGH_SPEED_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 4,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetMacHighSpeed(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_HIGH_SPEED,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 4,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_HIGH_LINE_SPEED_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 5,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetMacHighLineSpeed(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_HIGH_LINE_SPEED,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 5,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_YARN_BEFORE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 6,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%d", GetYarnBefore(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_YARN_BEFORE,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 6,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_ROLL_STOP_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 7,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetRabStopTorque(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_RAB_STOP,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 7,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_RET_LEN_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 8,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetMacRetLen(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_RET_LEN,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 8,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_BACK_SINK_RESET_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 9,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%d", GetBackSinkResetValue(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_BACK_SINK_RESET,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 9,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);
    //mid
    CreateWindow (MH_LABEL_NAME,
        MW_FRNT_SINK_RESET_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 10,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%d", GetFrontSinkResetValue(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_FRONT_SINK_RESET,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 10,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);
    CreateWindow (MH_LABEL_NAME,
        MW_AUTO_RESET_NUM_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 11,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetAutoZeroCloth(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_AUTO_RESET_NUM,
        START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 11,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CreateWindow (MH_LABEL_NAME,
        MW_SCREEN_SAVE_TIME_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetSaveScreenTime(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_SCREEN_SAVE_TIME,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_SCREEN_SAVE_ENABLE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 1,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);

    CreateWindow (MH_EDIT_NAME,
        GetSaveScreenEnable(g_knit_data) ? MW_YES_CAPTION : MW_NO_CAPTION,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_SCREEN_SAVE_ENABLE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 1,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_SHAKE_ENABLE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 2,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow (MH_EDIT_NAME,
        GetGauzeType(g_knit_data) ? GetString(770) : GetString(771),
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_SHAKE_ENABLE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) *2,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_FRNT_SHAKE_SENSE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) *3,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetFrontShakeSense(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_FRONT_SHAKE_SENSE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 3,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_BACK_SHAKE_SENSE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 4,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetBackShakeSense(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_BACK_SHAKE_SENSE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 4,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_FRNT_SAFE_DOOR_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 5,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow (MH_EDIT_NAME,
        GetFrontSafeDoorEnable(g_knit_data) ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_FRONT_SAFE_DOOR,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 5,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_BACK_SAFE_DOOR_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 6,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow (MH_EDIT_NAME,
        GetBackSafeDoorEnable(g_knit_data) ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_BACK_SAFE_DOOR,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 6,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);
/////////////////////////////////////////////////////////////////
    CreateWindow (MH_LABEL_NAME,
        MW_MAST_ROLL_WARN_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 7,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetMacNum(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_RAB_WARN_ENABLE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 7,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);
    //right/////////////////////////////////////////////////////////////////////////////////////
    CreateWindow (MH_LABEL_NAME,
        MW_BOARD_ENABLE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 8,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow (MH_EDIT_NAME,
        GetBoardEnable(g_knit_data) ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_BOARD_ENABLE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 8,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_SCISSOR_ENABLE_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 9,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow (MH_EDIT_NAME,
        GetScissorEnable(g_knit_data) ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_SCISSOR_ENABLE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 9,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_ROLL_4STOP_CAPTION,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 10,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetStopRabRelax(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_RAB_OPEN,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 10,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_YARN_MODE_TAKE,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 11,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetYarnTakeMode(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_YARN_MODE_TAKE,
        CX_SCREEN / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 11,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    const char *scc[5] = {
            GetString(600), GetString(601), GetString(604), GetString(605),
            GetString(615),
    };
    char edit[5][64] = {{0}};
    sprintf(edit[0], "%u", GetSecondDumuCom(g_knit_data));
    strcat(edit[1], GetYarnFeederMode(g_knit_data) ? GetString(603) : GetString(602));
    sprintf(edit[2], "%u", GetProbeShield(g_knit_data));
    sprintf(edit[3], "%d", GetDumuAddPercent(g_knit_data));
    strcat(edit[4], GetTranDumuEnable(g_knit_data) ? GetString(338) : GetString(339));
    int id[5] = {
            IDC_EDIT_2DUMU,
            IDC_EDIT_YF,
            IDC_EDIT_PROBE,
            IDC_EDIT_DUMU_ADD,
            IDC_EDIT_TRAN_DUMU,
    };
    int i = 0;
    for(i = 0; i < 5; ++i)
    {
        CreateWindow(MH_LABEL_NAME,
            scc[i],
            WS_CHILD | WS_VISIBLE | BS_LEFT,
            IDC_STATIC,
            559,
            66 + 30 * i ,
            160,
            24,
            hWnd, MH_LABEL_TEXT_GREEN | MH_LABEL_BKGND_BLACK);
        CreateWindow(MH_EDIT_NAME,
            edit[i],
            WS_CHILD | WS_VISIBLE,
            id[i],
            719,
            66 + 30 * i ,
            60,
            24,
            hWnd, 0);
    }

    CreateWindow (MH_LABEL_NAME,
        MW_AUTO_LINE_SET,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN * 2 / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 5,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetAutoLineSet(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_AUTO_LINE_SET,
        CX_SCREEN * 2 / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 5,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_RETURN_STATE,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN * 2 / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 6,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetReturnState(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_RETURN_STATE,
        CX_SCREEN * 2 / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 6,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    CreateWindow (MH_LABEL_NAME,
        MW_COPY_RAB_ENABLE,
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_STATIC,
        CX_SCREEN * 2 / 3 + START_POINT_CAPTION_LEFT,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 7,
        START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, MH_LABEL_COLOR_1GROUP);
    sprintf(sc, "%u", GetRabCopyEnable(g_knit_data));
    CreateWindow (MH_EDIT_NAME,
        sc,
        WS_CHILD | WS_VISIBLE,
        IDC_EDIT_COPY_RAB_ENABLE,
        CX_SCREEN * 2 / 3 + START_POINT_CAPTION_LEFT + START_POINT_CAPTION_WIDTH,
        START_POINT_CAPTION_TOP + (START_POINT_CAPTION_HEIGHT + START_POINT_INTER) * 7,
        START_POINT_NAME_WIDTH,
        START_POINT_CAPTION_HEIGHT,
        hWnd, 0);

    //tip
    CreateWindow(MH_LABEL_NAME,
        GetString(712),
        WS_CHILD | WS_VISIBLE | BS_LEFT,
        IDC_TIP,
        150,
        CY_XTCS_WND_BMP - 35,
        500,
        20,
        hWnd, MH_LABEL_BKGND_2GREEN | MH_LABEL_TEXT_YELLOW);
}
/*
 *把界面内有变更的数据传给g_knit_data
 */
static void OnSetKnitValue(HWND hWnd, int nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
    const char *sc = GetWindowCaption(GetDlgItem(hWnd, nID));
    switch(nID)
    {
    case IDC_EDIT_START_POINT:
        {
            ushort n = atoi(sc);
            SetStartNeedle(g_knit_data, n);
            if(g_hwnd_run > 0)
            {
                FlushRunWndStartPoint(g_hwnd_run);
            }
            data.work.change.work = TRUE;
            data.work.change.reset = TRUE;
        }
        break;
    case IDC_EDIT_LOW_SPEED:
        {
            uchar n = atoi(sc);
            SetMacLowSpeed(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_RESET_SPEED:
        {
            uchar n = atoi(sc);
            SetMacEmptySpeed(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_MID_SPEED:
        {
            uchar n = atoi(sc);
            SetMacMidSpeed(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_HIGH_SPEED:
        {
            uchar n = atoi(sc);
            SetMacHighSpeed(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_HIGH_LINE_SPEED:
        {
            uchar n = atoi(sc);
            SetMacHighLineSpeed(g_knit_data, n);
            data.work.change.other = TRUE;
        }
        break;
    case IDC_EDIT_YARN_BEFORE:
        {
            int n = atoi(sc);
            SetYarnBefore(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_RAB_STOP:
        {
            uchar n = atoi(sc);
            SetRabStopTorque(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_RET_LEN:
        {
            uchar n = atoi(sc);
            SetMacRetLen(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_BACK_SINK_RESET:
        {
            int n = atoi(sc);
            SetBackSinkResetValue(g_knit_data, n);
            if(ResetKnitSink(g_knit_data, TRUE))
            {
                AfxInfoBox(hWnd, NULL, GetString(441));
            }
            data.work.change.sys = TRUE;
        }
        break;
    case IDC_EDIT_FRONT_SINK_RESET:
        {
            int n = atoi(sc);
            SetFrontSinkResetValue(g_knit_data, n);
            if(ResetKnitSink(g_knit_data, FALSE))
            {
                AfxInfoBox(hWnd, NULL, GetString(436));
            }
            data.work.change.sys = TRUE;
        }
        break;
    case IDC_EDIT_AUTO_RESET_NUM:
        {
            ushort n = atoi(sc);
            SetAutoZeroCloth(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_SCREEN_SAVE_TIME:
        {
            uchar n = atoi(sc);
            SetSaveScreenTime(g_knit_data, n);
            data.work.change.work = TRUE;
            data.work.change.other = TRUE;
        }
        break;
    case IDC_EDIT_SCREEN_SAVE_ENABLE:
        break;
    case IDC_EDIT_SHAKE_ENABLE:
        break;
    case IDC_EDIT_FRONT_SHAKE_SENSE:
        {
            uchar n = atoi(sc);
            SetFrontShakeSense(g_knit_data, n);
            data.work.change.sys = TRUE;
        }
        break;
    case IDC_EDIT_BACK_SHAKE_SENSE:
        {
            uchar n = atoi(sc);
            SetBackShakeSense(g_knit_data, n);
            data.work.change.other = TRUE;
        }
        break;
    case IDC_EDIT_FRONT_SAFE_DOOR:
        break;
    case IDC_EDIT_BACK_SAFE_DOOR:
        break;
    case IDC_EDIT_RAB_WARN_ENABLE:
        {
            uint n = atoi(sc);
            SetMacNum(g_knit_data, n);
            data.work.change.other = TRUE;
        }
        break;
    case IDC_EDIT_BOARD_ENABLE:
        break;
    case IDC_EDIT_SCISSOR_ENABLE:
        break;
    case IDC_EDIT_RAB_OPEN:
        {
            uchar n = atoi(sc);
            SetStopRabRelax(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_2DUMU:
        {
            char n = atoi(sc);
            SetSecondDumuCom(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_PROBE:
        {
            uchar n = atoi(sc);
            SetProbeShield(g_knit_data, n);
            data.work.change.hide = TRUE;
        }
        break;
    case IDC_EDIT_DUMU_ADD:
        {
            uchar n = atoi(sc);
            SetDumuAddPercent(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_YARN_MODE_TAKE:
        {
            uchar n = atoi(sc);
            SetYarnTakeMode(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_RETURN_STATE:
        {
            uchar n = atoi(sc);
            SetReturnState(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_COPY_RAB_ENABLE:
        {
            uchar n = atoi(sc);
            SetRabCopyEnable(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    case IDC_EDIT_AUTO_LINE_SET:
        {
            uchar n = atoi(sc);
            SetAutoLineSet(g_knit_data, n);
            data.work.change.work = TRUE;
        }
        break;
    }
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *设置好控件对象值的范围和对象区域作为参数给创建键盘对象
 */
static void OnCreateKeyboard(HWND hWnd, ushort nID)
{
    int index = 0;
    switch(nID)
    {
    case IDC_EDIT_START_POINT:
        index = 0;
        break;
    case IDC_EDIT_LOW_SPEED:
        index = 1;
        break;
    case IDC_EDIT_RESET_SPEED:
        index = 2;
        break;
    case IDC_EDIT_MID_SPEED:
        index = 3;
        break;
    case IDC_EDIT_HIGH_SPEED:
        index = 4;
        break;
    case IDC_EDIT_HIGH_LINE_SPEED:
        index = 5;
        break;
    case IDC_EDIT_YARN_BEFORE:
        index = 6;
        break;
    case IDC_EDIT_RAB_STOP:
        index = 7;
        break;
    case IDC_EDIT_RET_LEN:
        index = 8;
        break;
    case IDC_EDIT_BACK_SINK_RESET:
        index = 9;
        break;
    case IDC_EDIT_FRONT_SINK_RESET:
        index = 10;
        break;
    case IDC_EDIT_AUTO_RESET_NUM:
        index = 11;
        break;
    case IDC_EDIT_SCREEN_SAVE_TIME:
        index = 12;
        break;
    case IDC_EDIT_FRONT_SHAKE_SENSE:
        index = 13;
        break;
    case IDC_EDIT_BACK_SHAKE_SENSE:
        index = 14;
        break;
    case IDC_EDIT_RAB_WARN_ENABLE:
        index = 15;
        break;
    case IDC_EDIT_RAB_OPEN:
        index = 16;
         break;
     case IDC_EDIT_YARN_MODE_TAKE:
        index = 17;
        break;
    case IDC_EDIT_2DUMU:
        index = 18;
        break;
    case IDC_EDIT_PROBE:
        index = 19;
        break;
    case IDC_EDIT_DUMU_ADD:
        index = 20;
        break;
    case IDC_EDIT_AUTO_LINE_SET:
        index = 21;
        break;
    case IDC_EDIT_RETURN_STATE:
        index = 22;
        break;
    case IDC_EDIT_COPY_RAB_ENABLE:
        index = 23;
        break;
    }
    int area[31][2] = { { 1, 640 }, { 5, 30 }, { 0/*5*/, 120 }, { 1/*5*/, 40 },
            { 1/*60*/, 100 }, { 1/*60*/, 100 }, { -50, 50 }, { 0, 100 }, { 1/*5*/, 50 }, { 0,
                    650 }, { 0, 650 }, { 0, 100 }, { 0, 60 }, { 0, 100 },
            { 0, 100 },{ 0, 99999999 }, { 0, 100 }, {0, 1},
                    {0, 100}, {0, 500}, {0, 100}, {0,1},{0,1},{0,1}};
    HWND hTmp = GetDlgItem(hWnd, nID);
    RECT rect;
    GetClientRect(hTmp, &rect);
    ClientToScreen(hTmp, &rect.left, &rect.top);

    ClientToScreen(hTmp, &rect.right, &rect.bottom);
    int value = atoi(GetWindowCaption(hTmp));
    CreateKeyboardWindow(hWnd, rect, area[index][0], area[index][1], value);


}
/*
 *送纱器模式  0=编织时转 1=一直转 2=运行时转
 */
static void OnChangeFeederMode(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
    uchar n = GetYarnFeederMode(g_knit_data);
    ++n;
    if(n > 2)
    {
        n = 0;
    }
    SetYarnFeederMode(g_knit_data, n);
    const char *sc;
    if(n == 0)
    {
        sc = GetString(602);
    }
    else if(n == 1)
    {
        sc = GetString(699);
    }
    else if(n == 2)
    {
        sc = GetString(603);
    }
    HWND hTmp = GetDlgItem(hWnd, nID);
    SetWindowCaption(hTmp, sc);
    InvalidateRect(hTmp, NULL, TRUE);

    data.work.change.sys = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *屏幕保护使能
 */
static void OnChangeSaveScreenEnable(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    uchar n = GetSaveScreenEnable(g_knit_data);
    n = !n;
    SetSaveScreenEnable(g_knit_data, n);
    SetWindowCaption(GetDlgItem(hWnd, nID), n ? MW_YES_CAPTION : MW_NO_CAPTION);
    InvalidateRect(GetDlgItem(hWnd, nID), NULL, TRUE);

    data.work.change.other = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *
 */
static void OnChangeGauzeType(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    uchar n = GetGauzeType(g_knit_data);
    n = !n;
    SetGauzeType(g_knit_data, n);
    SetWindowCaption(GetDlgItem(hWnd, nID), n ? GetString(770) : GetString(771));
    InvalidateRect(GetDlgItem(hWnd, nID), NULL, TRUE);

    data.work.change.sys = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *前安全门报警
 */
static void OnChangeFrontSafeDoor(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    uchar n = GetFrontSafeDoorEnable(g_knit_data);
    n = !n;
    SetFrontSafeDoorEnable(g_knit_data, n);
    SetWindowCaption(GetDlgItem(hWnd, nID), n ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION);
    InvalidateRect(GetDlgItem(hWnd, nID), NULL, TRUE);

    data.work.change.other = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *后安全门报警
 */
static void OnChangeBackSafeDoor(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    uchar n = GetBackSafeDoorEnable(g_knit_data);
    n = !n;
    SetBackSafeDoorEnable(g_knit_data, n);
    SetWindowCaption(GetDlgItem(hWnd, nID), n ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION);
    InvalidateRect(GetDlgItem(hWnd, nID), NULL, TRUE);

    data.work.change.other = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *起底板使能
 */
static void OnBoardEnable(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    uchar n = GetBoardEnable(g_knit_data);
    n = !n;
    SetBoardEnable(g_knit_data, n);
    SetWindowCaption(GetDlgItem(hWnd, nID), n ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION);
    InvalidateRect(GetDlgItem(hWnd, nID), NULL, TRUE);

    data.work.change.sys = TRUE;
    data.work.change.reset = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *剪刀使能
 */
static void OnScissorEnable(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    uchar n = GetScissorEnable(g_knit_data);
    n = !n;
    SetScissorEnable(g_knit_data, n);

    SetWindowCaption(GetDlgItem(hWnd, nID), n ? MW_OPEN_CAPTION : MW_CLOSE_CAPTION);
    InvalidateRect(GetDlgItem(hWnd, nID), NULL, TRUE);

    data.work.change.other = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *翻针度目使能
 */
static void OnTranDumuEnable(HWND hWnd, ushort nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);

    int n = GetTranDumuEnable(g_knit_data);
    n = !n;
    SetTranDumuEnable(g_knit_data, n);

    HWND hTmp = GetDlgItem(hWnd, nID);
    SetWindowCaption(hTmp, n ? GetString(338) : GetString(339));
    InvalidateRect(hTmp, NULL, TRUE);

    data.work.change.hide = TRUE;
    SetWindowAdditionalData(hWnd, data.value);
}
/*
 *界面下方的警告提醒
 */
static void OnChangeCtrl(HWND hWnd)
{
    HWND hTmp = GetFocusChild(hWnd);
    ushort nID = GetDlgCtrlID(hTmp);
    const char *sc = "";
    switch (nID)
    {
    case IDC_EDIT_START_POINT:
        sc = GetString(712);
        break;
    case IDC_EDIT_LOW_SPEED:
        sc = GetString(713);
        break;
    case IDC_EDIT_RESET_SPEED:
        sc = GetString(714);
        break;
    case IDC_EDIT_MID_SPEED:
        sc = GetString(715);
        break;
    case IDC_EDIT_HIGH_SPEED:
        sc = GetString(716);
        break;
    case IDC_EDIT_HIGH_LINE_SPEED:
        sc = GetString(717);
        break;
    case IDC_EDIT_YARN_BEFORE:
        sc = GetString(718);
        break;
    case IDC_EDIT_RAB_STOP:
        sc = GetString(719);
        break;
    case IDC_EDIT_RET_LEN:
        sc = GetString(720);
        break;
    case IDC_EDIT_BACK_SINK_RESET:
        sc = GetString(721);
        break;
    case IDC_EDIT_FRONT_SINK_RESET:
        sc = GetString(722);
        break;
    case IDC_EDIT_AUTO_RESET_NUM:
        sc = GetString(723);
        break;
    case IDC_EDIT_SCREEN_SAVE_TIME:
        sc = GetString(724);
        break;
    case IDC_EDIT_SCREEN_SAVE_ENABLE:
        sc = GetString(725);
        break;
    case IDC_EDIT_SHAKE_ENABLE:
        sc = GetString(726);
        break;
    case IDC_EDIT_FRONT_SHAKE_SENSE:
        sc = GetString(727);
        break;
    case IDC_EDIT_BACK_SHAKE_SENSE:
        sc = GetString(728);
        break;
    case IDC_EDIT_FRONT_SAFE_DOOR:
        sc = GetString(729);
        break;
    case IDC_EDIT_BACK_SAFE_DOOR:
        sc = GetString(730);
        break;
    case IDC_EDIT_RAB_WARN_ENABLE:
        sc = GetString(731);
        break;
    case IDC_EDIT_BOARD_ENABLE:
        sc = GetString(732);
        break;
    case IDC_EDIT_SCISSOR_ENABLE:
        sc = GetString(733);
        break;
    case IDC_EDIT_RAB_OPEN:
        sc = GetString(734);
        break;
    case IDC_EDIT_2DUMU:
        sc = GetString(735);
        break;
    case IDC_EDIT_YF:
        sc = GetString(736);
        break;
    case IDC_EDIT_PROBE:
        sc = GetString(737);
        break;
    case IDC_EDIT_DUMU_ADD:
        sc = GetString(738);
        break;
    case IDC_EDIT_TRAN_DUMU:
        sc = GetString(739);
        break;
        case IDC_EDIT_YARN_MODE_TAKE:
        sc = GetString(815);
        break;
    case IDC_EDIT_RETURN_STATE:
        sc = GetString(816);
        break;
    case IDC_EDIT_AUTO_LINE_SET:
        sc = GetString(817);
        break;
    case IDC_EDIT_COPY_RAB_ENABLE:
        sc = GetString(818);
        break;
    }
    hTmp = GetDlgItem(hWnd, IDC_TIP);
    SetWindowCaption(hTmp, sc);
    InvalidateRect(hTmp, NULL, TRUE);
}
/*
 *
 */
static void OnBtnCmd(HWND hWnd, int nID)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
	switch(nID)
	{
	case ID_ESC:
	    {
	        if(data.work.change.reset)
	        {
	            SetWhichNeedDo(g_knit_data, NEED_DO_RESET_START);
	        }
	        if(data.work.change.all)
            {
                int ret = WriteMacFile(MAC_PARAM_FILE, g_knit_data);
                if(ret)
                {
                    printf("write param: %d\n", ret);
                    AfxInfoBox(hWnd, NULL, GetString(481));
                }
                else
                {
                    MH_FILE_SYNC();
                }
            }
	        if(data.work.change.sys)
	        {
	            SendSysParam(g_knit_data);
	        }
	        if(data.work.change.work)
	        {
	            SendWorkParam(g_knit_data);
	        }
	        if(data.work.change.hide)
            {
                SendHideParam(g_knit_data);
            }
	    	PostMessage (hWnd, MSG_CLOSE, 0, 0);
	    }
		break;
	case IDC_EDIT_START_POINT:
	case IDC_EDIT_BACK_SINK_RESET:
	case IDC_EDIT_FRONT_SINK_RESET:
	    if(STATE_STOP != GetRunState(g_knit_data))
	    {
	        return;
	    }
	    else
	    {
	        SwitchToKnitState(g_knit_data, FALSE);
	    }
	case IDC_EDIT_LOW_SPEED:
	case IDC_EDIT_RESET_SPEED:
	case IDC_EDIT_MID_SPEED:
	case IDC_EDIT_HIGH_SPEED:
	case IDC_EDIT_HIGH_LINE_SPEED:
	case IDC_EDIT_YARN_BEFORE:
	case IDC_EDIT_RAB_STOP:
	case IDC_EDIT_RET_LEN:
	case IDC_EDIT_AUTO_RESET_NUM:
	case IDC_EDIT_SCREEN_SAVE_TIME:
	case IDC_EDIT_FRONT_SHAKE_SENSE:
	case IDC_EDIT_BACK_SHAKE_SENSE:
	case IDC_EDIT_RAB_OPEN:
	case IDC_EDIT_2DUMU:
	case IDC_EDIT_PROBE:
	case IDC_EDIT_DUMU_ADD:
	case IDC_EDIT_RAB_WARN_ENABLE:
    case IDC_EDIT_YARN_MODE_TAKE:
    case IDC_EDIT_RETURN_STATE:
    case IDC_EDIT_AUTO_LINE_SET:
    case IDC_EDIT_COPY_RAB_ENABLE:
	    {
	        OnCreateKeyboard(hWnd, nID);
	    }
	    break;
	case IDC_EDIT_YF:
	    {
	        OnChangeFeederMode(hWnd, IDC_EDIT_YF);
	    }
	    break;
	case IDC_EDIT_SCREEN_SAVE_ENABLE:
	    {
	        OnChangeSaveScreenEnable(hWnd, nID);
	    }
	    break;
	case IDC_EDIT_SHAKE_ENABLE:
	    {
	      //  OnChangeShakeEnable(hWnd, nID);
	    }
	    break;
	case IDC_EDIT_FRONT_SAFE_DOOR:
	    {
	        OnChangeFrontSafeDoor(hWnd, nID);
	    }
	    break;
	case IDC_EDIT_BACK_SAFE_DOOR:
	    {
	        OnChangeBackSafeDoor(hWnd, nID);
	    }
	    break;
	case IDC_EDIT_BOARD_ENABLE:
	    if(STATE_STOP == GetRunState(g_knit_data))
	    {
	        OnBoardEnable(hWnd, nID);
	    }
	    break;
	case IDC_EDIT_SCISSOR_ENABLE:
	    if(STATE_STOP == GetRunState(g_knit_data))
	    {
	        OnScissorEnable(hWnd, nID);
	    }
	    break;
    case IDC_EDIT_TRAN_DUMU:
	    {
	        OnTranDumuEnable(hWnd, nID);
	    }
	    break;
	}
}
/*
 *
 */
static void DoEvent(HWND hWnd, ushort nID)
{
    printf("DoEvent ID:%d\n",nID);
    switch(nID)
    {
    case IDC_EDIT_TRAN_DUMU:
        {
            OnTranDumuEnable(hWnd, nID);
        }
        break;
    case IDC_EDIT_YF:
        {
            OnChangeFeederMode(hWnd, nID);
        }
        break;
    case IDC_EDIT_SCREEN_SAVE_ENABLE:
        {
            OnChangeSaveScreenEnable(hWnd, nID);
        }
        break;
    case IDC_EDIT_SHAKE_ENABLE:
        {
            OnChangeGauzeType(hWnd, nID);
        }
        break;
    case IDC_EDIT_FRONT_SAFE_DOOR:
        {
            OnChangeFrontSafeDoor(hWnd, nID);
        }
        break;
    case IDC_EDIT_BACK_SAFE_DOOR:
        {
            OnChangeBackSafeDoor(hWnd, nID);
        }
        break;
    case IDC_EDIT_BOARD_ENABLE:
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            OnBoardEnable(hWnd, nID);
        }
        break;
    case IDC_EDIT_SCISSOR_ENABLE:
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            OnScissorEnable(hWnd, nID);
        }
        break;
    default:
        {
            OnBtnCmd(hWnd, nID);
        }
        break;
    }
}
/*
 *
 */
static void OnKeyDown(HWND hWnd, uint key)
{
	if(key == SCANCODE_ESCAPE)
	{
		OnBtnCmd(hWnd, ID_ESC);
	}
    else if(key == SCANCODE_CURSORBLOCKLEFT)
    {
        uint nID = 0;
        switch(GetDlgCtrlID(GetFocusChild(hWnd)))
        {
        case IDC_EDIT_SCREEN_SAVE_TIME:
            nID = IDC_EDIT_START_POINT;
            break;
        case IDC_EDIT_SCREEN_SAVE_ENABLE:
            nID = IDC_EDIT_LOW_SPEED;
            break;
        case IDC_EDIT_SHAKE_ENABLE:
            nID = IDC_EDIT_RESET_SPEED;
            break;
        case IDC_EDIT_FRONT_SHAKE_SENSE:
            nID =  IDC_EDIT_MID_SPEED;
            break;
        case IDC_EDIT_BACK_SHAKE_SENSE:
            nID = IDC_EDIT_HIGH_SPEED;
            break;
        case IDC_EDIT_FRONT_SAFE_DOOR:
            nID = IDC_EDIT_HIGH_LINE_SPEED;
            break;
        case IDC_EDIT_BACK_SAFE_DOOR:
            nID = IDC_EDIT_YARN_BEFORE;
            break;
        case IDC_EDIT_RAB_WARN_ENABLE:
            nID = IDC_EDIT_RAB_STOP;
            break;
        case IDC_EDIT_BOARD_ENABLE:
            nID = IDC_EDIT_RET_LEN;
            break;
        case IDC_EDIT_SCISSOR_ENABLE:
            nID = IDC_EDIT_BACK_SINK_RESET;
            break;
         case IDC_EDIT_RAB_OPEN:
            nID = IDC_EDIT_FRONT_SINK_RESET;
            break;
         case IDC_EDIT_YARN_MODE_TAKE:
            nID =  IDC_EDIT_AUTO_RESET_NUM;
            break;
        case IDC_EDIT_2DUMU:
            nID = IDC_EDIT_SCREEN_SAVE_TIME;
            break;
        case IDC_EDIT_YF:
            nID = IDC_EDIT_SCREEN_SAVE_ENABLE;
            break;
        case IDC_EDIT_PROBE:
            nID = IDC_EDIT_SHAKE_ENABLE;
            break;
        case IDC_EDIT_DUMU_ADD:
            nID = IDC_EDIT_FRONT_SHAKE_SENSE;
            break;
        case IDC_EDIT_TRAN_DUMU:
            nID = IDC_EDIT_BACK_SHAKE_SENSE;
            break;
        case IDC_EDIT_AUTO_LINE_SET:
            nID = IDC_EDIT_FRONT_SAFE_DOOR;
            break;
        case IDC_EDIT_RETURN_STATE:
            nID = IDC_EDIT_BACK_SAFE_DOOR;
            break;
        case IDC_EDIT_COPY_RAB_ENABLE:
            nID = IDC_EDIT_RAB_WARN_ENABLE;
        default:
            break;
        }
        if(nID)
	    {
	        SetFocusChild(GetDlgItem(hWnd, nID));
	    }
    }
    else if(key == SCANCODE_CURSORBLOCKRIGHT)
    {
        uint nID = 0;
        switch(GetDlgCtrlID(GetFocusChild(hWnd)))
        {
        case IDC_EDIT_START_POINT:
            nID = IDC_EDIT_SCREEN_SAVE_TIME;
            break;
        case IDC_EDIT_LOW_SPEED:
            nID = IDC_EDIT_SCREEN_SAVE_ENABLE;
            break;
        case IDC_EDIT_RESET_SPEED:
            nID = IDC_EDIT_SHAKE_ENABLE;
            break;
        case IDC_EDIT_MID_SPEED:
            nID = IDC_EDIT_FRONT_SHAKE_SENSE;
            break;
        case IDC_EDIT_HIGH_SPEED:
            nID = IDC_EDIT_BACK_SHAKE_SENSE;
            break;
        case IDC_EDIT_HIGH_LINE_SPEED:
            nID = IDC_EDIT_FRONT_SAFE_DOOR;
            break;
        case IDC_EDIT_YARN_BEFORE:
            nID = IDC_EDIT_BACK_SAFE_DOOR;
            break;
        case IDC_EDIT_RAB_STOP:
            nID = IDC_EDIT_RAB_WARN_ENABLE;
            break;
        case IDC_EDIT_RET_LEN:
            nID = IDC_EDIT_BOARD_ENABLE;
            break;
        case IDC_EDIT_BACK_SINK_RESET:
            nID = IDC_EDIT_SCISSOR_ENABLE;
            break;
        case IDC_EDIT_FRONT_SINK_RESET:
            nID = IDC_EDIT_RAB_OPEN;
            break;
        case IDC_EDIT_AUTO_RESET_NUM:
            nID = IDC_EDIT_YARN_MODE_TAKE;
            break;
        case IDC_EDIT_SCREEN_SAVE_TIME:
            nID = IDC_EDIT_2DUMU;
            break;
        case IDC_EDIT_SCREEN_SAVE_ENABLE:
            nID = IDC_EDIT_YF;
            break;
        case IDC_EDIT_SHAKE_ENABLE:
            nID = IDC_EDIT_PROBE;
            break;
        case IDC_EDIT_FRONT_SHAKE_SENSE:
            nID = IDC_EDIT_DUMU_ADD;
            break;
        case IDC_EDIT_BACK_SHAKE_SENSE:
            nID = IDC_EDIT_TRAN_DUMU;
            break;
        case IDC_EDIT_FRONT_SAFE_DOOR:
            nID = IDC_EDIT_AUTO_LINE_SET;
            break;
        case IDC_EDIT_BACK_SAFE_DOOR:
            nID = IDC_EDIT_RETURN_STATE;
            break;
        case IDC_EDIT_RAB_WARN_ENABLE:
            nID = IDC_EDIT_COPY_RAB_ENABLE;
            break;
        case IDC_EDIT_BOARD_ENABLE:
        case IDC_EDIT_SCISSOR_ENABLE:
        case IDC_EDIT_RAB_OPEN:
        case IDC_EDIT_YARN_MODE_TAKE:
            nID = IDC_EDIT_COPY_RAB_ENABLE;
            break;

        default:
            break;
        }
        if(nID)
	    {
	        SetFocusChild(GetDlgItem(hWnd, nID));
	    }
    }
    else if(key == SCANCODE_CURSORBLOCKUP)
    {
        uint nID = 0;
        switch(GetDlgCtrlID(GetFocusChild(hWnd)))
        {
        case IDC_EDIT_LOW_SPEED:
            nID = IDC_EDIT_START_POINT;
            break;
        case IDC_EDIT_RESET_SPEED:
            nID = IDC_EDIT_LOW_SPEED;
            break;
        case IDC_EDIT_MID_SPEED:
            nID = IDC_EDIT_RESET_SPEED;
            break;
        case IDC_EDIT_HIGH_SPEED:
            nID = IDC_EDIT_MID_SPEED;
            break;
        case IDC_EDIT_HIGH_LINE_SPEED:
            nID = IDC_EDIT_HIGH_SPEED;
            break;
        case IDC_EDIT_YARN_BEFORE:
            nID = IDC_EDIT_HIGH_LINE_SPEED;
            break;
        case IDC_EDIT_RAB_STOP:
            nID = IDC_EDIT_YARN_BEFORE;
            break;
        case IDC_EDIT_RET_LEN:
            nID = IDC_EDIT_RAB_STOP;
            break;
        case IDC_EDIT_BACK_SINK_RESET:
            nID = IDC_EDIT_RET_LEN;
            break;
        case IDC_EDIT_FRONT_SINK_RESET:
            nID = IDC_EDIT_BACK_SINK_RESET;
            break;
        case IDC_EDIT_AUTO_RESET_NUM:
            nID = IDC_EDIT_FRONT_SINK_RESET;
            break;
        case IDC_EDIT_SCREEN_SAVE_TIME:
            nID = IDC_EDIT_AUTO_RESET_NUM;
            break;
        case IDC_EDIT_SCREEN_SAVE_ENABLE:
            nID =  IDC_EDIT_SCREEN_SAVE_TIME;
            break;
        case IDC_EDIT_SHAKE_ENABLE:
            nID = IDC_EDIT_SCREEN_SAVE_ENABLE;
            break;
        case IDC_EDIT_FRONT_SHAKE_SENSE:
            nID = IDC_EDIT_SHAKE_ENABLE;
            break;
        case IDC_EDIT_BACK_SHAKE_SENSE:
            nID = IDC_EDIT_FRONT_SHAKE_SENSE;
            break;
        case IDC_EDIT_FRONT_SAFE_DOOR:
            nID = IDC_EDIT_BACK_SHAKE_SENSE;
            break;
        case IDC_EDIT_BACK_SAFE_DOOR:
            nID = IDC_EDIT_FRONT_SAFE_DOOR;
            break;
        case IDC_EDIT_RAB_WARN_ENABLE:
            nID = IDC_EDIT_BACK_SAFE_DOOR;
            break;
        case IDC_EDIT_BOARD_ENABLE:
            nID = IDC_EDIT_RAB_WARN_ENABLE;
            break;
        case IDC_EDIT_SCISSOR_ENABLE:
            nID = IDC_EDIT_BOARD_ENABLE;
            break;
        case IDC_EDIT_RAB_OPEN:
            nID = IDC_EDIT_SCISSOR_ENABLE;
            break;
        case IDC_EDIT_YARN_MODE_TAKE:
            nID = IDC_EDIT_RAB_OPEN;
            break;
        case IDC_EDIT_2DUMU:
            nID = IDC_EDIT_YARN_MODE_TAKE;
            break;
        case IDC_EDIT_YF:
            nID = IDC_EDIT_2DUMU;
            break;
        case IDC_EDIT_PROBE:
            nID = IDC_EDIT_YF;
            break;
        case IDC_EDIT_DUMU_ADD:
            nID = IDC_EDIT_PROBE;
            break;
        case IDC_EDIT_TRAN_DUMU:
            nID = IDC_EDIT_DUMU_ADD;
            break;
        case IDC_EDIT_AUTO_LINE_SET:
            nID = IDC_EDIT_TRAN_DUMU;
            break;
        case IDC_EDIT_RETURN_STATE:
            nID = IDC_EDIT_AUTO_LINE_SET;
            break;
        case IDC_EDIT_COPY_RAB_ENABLE:
            nID = IDC_EDIT_RETURN_STATE;
            break;
        default:
            break;
        }
        if(nID)
	    {
	        SetFocusChild(GetDlgItem(hWnd, nID));
	    }
    }
    else if(key == SCANCODE_CURSORBLOCKDOWN)
    {
        uint nID = 0;
        switch(GetDlgCtrlID(GetFocusChild(hWnd)))
        {
        case IDC_EDIT_START_POINT:
            nID = IDC_EDIT_LOW_SPEED;
            break;
        case IDC_EDIT_LOW_SPEED:
            nID = IDC_EDIT_RESET_SPEED;
            break;
        case IDC_EDIT_RESET_SPEED:
            nID = IDC_EDIT_MID_SPEED;
            break;
        case IDC_EDIT_MID_SPEED:
            nID = IDC_EDIT_HIGH_SPEED;
            break;
        case IDC_EDIT_HIGH_SPEED:
            nID = IDC_EDIT_HIGH_LINE_SPEED;
            break;
        case IDC_EDIT_HIGH_LINE_SPEED:
            nID = IDC_EDIT_YARN_BEFORE;
            break;
        case IDC_EDIT_YARN_BEFORE:
            nID = IDC_EDIT_RAB_STOP;
            break;
        case IDC_EDIT_RAB_STOP:
            nID = IDC_EDIT_RET_LEN;
            break;
        case IDC_EDIT_RET_LEN:
            nID = IDC_EDIT_BACK_SINK_RESET;
            break;
        case IDC_EDIT_BACK_SINK_RESET:
            nID = IDC_EDIT_FRONT_SINK_RESET;
            break;
        case IDC_EDIT_FRONT_SINK_RESET:
            nID = IDC_EDIT_AUTO_RESET_NUM;
            break;
        case IDC_EDIT_AUTO_RESET_NUM:
            nID = IDC_EDIT_SCREEN_SAVE_TIME;
            break;
        case IDC_EDIT_SCREEN_SAVE_TIME:
            nID = IDC_EDIT_SCREEN_SAVE_ENABLE;
            break;
        case IDC_EDIT_SCREEN_SAVE_ENABLE:
            nID =  IDC_EDIT_SHAKE_ENABLE;
            break;
        case IDC_EDIT_SHAKE_ENABLE:
            nID = IDC_EDIT_FRONT_SHAKE_SENSE;
            break;
        case IDC_EDIT_FRONT_SHAKE_SENSE:
            nID = IDC_EDIT_BACK_SHAKE_SENSE;
            break;
        case IDC_EDIT_BACK_SHAKE_SENSE:
            nID = IDC_EDIT_FRONT_SAFE_DOOR;
            break;
        case IDC_EDIT_FRONT_SAFE_DOOR:
            nID = IDC_EDIT_BACK_SAFE_DOOR;
            break;
        case IDC_EDIT_BACK_SAFE_DOOR:
            nID = IDC_EDIT_RAB_WARN_ENABLE;
            break;
        case IDC_EDIT_RAB_WARN_ENABLE:
            nID = IDC_EDIT_BOARD_ENABLE;
            break;
        case IDC_EDIT_BOARD_ENABLE:
            nID = IDC_EDIT_SCISSOR_ENABLE;
            break;
        case IDC_EDIT_SCISSOR_ENABLE:
            nID = IDC_EDIT_RAB_OPEN;
            break;
        case IDC_EDIT_RAB_OPEN:
            nID = IDC_EDIT_YARN_MODE_TAKE;
            break;
        case IDC_EDIT_YARN_MODE_TAKE:
            nID = IDC_EDIT_2DUMU;
            break;
        case IDC_EDIT_2DUMU:
            nID = IDC_EDIT_YF;
            break;
        case IDC_EDIT_YF:
            nID = IDC_EDIT_PROBE;
            break;
        case IDC_EDIT_PROBE:
            nID = IDC_EDIT_DUMU_ADD;
            break;
        case IDC_EDIT_DUMU_ADD:
            nID = IDC_EDIT_TRAN_DUMU;
            break;
        case IDC_EDIT_TRAN_DUMU:
            nID = IDC_EDIT_AUTO_LINE_SET;
            break;
        case IDC_EDIT_AUTO_LINE_SET:
            nID = IDC_EDIT_RETURN_STATE;
            break;
        case IDC_EDIT_RETURN_STATE:
            nID = IDC_EDIT_COPY_RAB_ENABLE;
            break;
        default:
            break;
        }
        if(nID)
	    {
	        SetFocusChild(GetDlgItem(hWnd, nID));
	    }
    }
    else if(key == SCANCODE_ENTER)
    {
        ushort nID = GetDlgCtrlID(GetFocusChild(hWnd));
        DoEvent(hWnd, nID);
    }
}
/*
 *
 */
static int WorkWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
    {
    case MSG_CREATE:
        {
        	CreateWorkInterface(hWnd);
        }
        break;
    case MSG_PAINT:
        {
            HDC hdc = GetClientDC(hWnd);
            RECT rect;
            GetClientRect(hWnd, &rect);
            rect.left += 200;
            rect.top += MASTER_TITLE_TOP;
            rect.right -= 200;
            rect.bottom = rect.top + MASTER_TITLE_HEIGHT - 1;
            SetBkMode(hdc, BM_TRANSPARENT);
            SetTextColor(hdc, COLOR_HQ_GREEN(hdc));
            DrawText(hdc, GetWindowCaption (hWnd), -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
            ReleaseDC(hdc);
        }
        break;
    case MSG_CLOSE:
        {
            HWND hHosting = GetHosting(hWnd);
            if(hHosting != HWND_INVALID)
            {
                EnableWindow(hHosting, TRUE);
            }
            DestroyMainWindow(hWnd);
            MainWindowCleanup(hWnd);
        }
        return 0;
    case MSG_DESTROY:
        {
            ShowWindow(hWnd, SW_HIDE);
            DestroyAllControls(hWnd);
        }
        break;
    case MSG_KEYDOWN:
    	{
    	    OnKeyDown(hWnd, wParam);
    	    OnChangeCtrl(hWnd);
    	}
        return 0;
    case MSG_ERASEBKGND:
        {
            DrawBitmapBkGnd(hWnd, (RECT*)lParam, &g_bmp[BMP_WORK]);
        }
    	return 0;
    case MSG_COMMAND:
        {
            OnChangeCtrl(hWnd);
        	OnBtnCmd(hWnd, LOWORD(wParam));
        }
    	return 0;
    case MSG_SETDATA:
        OnSetKnitValue(hWnd, LOWORD(wParam));
        return 0;
    }
    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
/*
 *
 */
HWND CreateWorkWindow(HWND hHosting)
{
    int x = (CX_SCREEN - CX_XTCS_WND_BMP) / 2;
    int y = (CY_SCREEN - CY_XTCS_WND_BMP) / 2;
    MAINWINCREATE CreateInfo;
    CreateInfo.dwStyle = WS_VISIBLE;
    CreateInfo.dwExStyle = WS_EX_NONE;
    CreateInfo.spCaption = MW_WORK_TITLE_CAPTION;
    CreateInfo.hMenu = 0;
    CreateInfo.hCursor = GetSystemCursor(0);
    CreateInfo.hIcon = 0;
    CreateInfo.MainWindowProc = WorkWinProc;
    CreateInfo.lx = x;
    CreateInfo.ty = y;
    CreateInfo.rx = x + CX_XTCS_WND_BMP;
    CreateInfo.by = y + CY_XTCS_WND_BMP;
    CreateInfo.iBkColor = COLOR_lightwhite;
    CreateInfo.dwAddData = 0;
    CreateInfo.hHosting = hHosting;
    HWND hWnd = CreateMainWindow(&CreateInfo);
    if(hWnd != HWND_INVALID)
    {
        EnableWindow(hHosting, FALSE);
        SetFocusChild(GetDlgItem(hWnd, IDC_EDIT_START_POINT));
        ShowWindow(hWnd, SW_SHOWNORMAL);
    }
    return hWnd;
}
